<template>
  <div class="DiaoyunlingDialog-page">
    <CommonHeader type="白" leftText="返回" :onLeft="dilogShow" :leftIcon="true" :title="dialogTitle"/>
    <div class="DiaoyunlingDialog-search-view">
      <van-icon name="search" color="#D4D4D4" class="DiaoyunlingDialog-search-icon"/>
      <input class="DiaoyunlingDialog-search-input" placeholder="请输入品种名称" type="text" v-model="searchText"/>
      <div class="DiaoyunlingDialog-search-button" @click="searchButtonClick">搜索</div>
    </div>
    <div class="DiaoyunlingDialog-list-page" v-if="'diaoyunliang'==props.dialogPageType||'qiye-diaoyunliang'==props.dialogPageType">
      <div class="DiaoyunlingDialog-list-item" v-for="(item,index) in listData" :key="index">
        <div class="DiaoyunlingDialog-list-item-pinzhong-view">
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">{{ item.varietyName }}</div>
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">{{ item.transportDate }}</div>
        </div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">调用量：{{ item.transportYield }}公斤</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">调出县：{{ item.targetLocation }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">调入县：{{ item.fromLocation }}</div>
      </div>
    </div>
    <div class="DiaoyunlingDialog-list-page" v-if="'beianzhexinxi'==props.dialogPageType||'qiye-beianzhexinxi' == props.dialogPageType">
      <div class="DiaoyunlingDialog-list-item" v-for="(item,index) in listData" :key="index">
        <div class="DiaoyunlingDialog-list-item-pinzhong-view">备案者名称：{{ item.filingEnterpriseName }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">联系人：{{ item.linkmanName }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">联系电话：{{ item.linkmanPhone }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">联系地址：{{ item.linkmanDomicile }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">品种名称：{{ item.varietyName }}</div>
      </div>
    </div>
    <div class="DiaoyunlingDialog-list-page" v-if="'mendiandaohuoliang'==props.dialogPageType||'qiye-mendiandaohuoliang'== props.dialogPageType">
      <div class="DiaoyunlingDialog-list-item" v-for="(item,index) in listData" :key="index">
        <div class="DiaoyunlingDialog-list-item-pinzhong-view">流水号：{{ item.filingNumber }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">品种名称：{{ item.varietyName }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">备案类型：{{ balx(item.filingType) }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">备案日期：{{ item.applyDate }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">种子数量：{{ item.maxSeedQuantity }}</div>
      </div>
    </div>
    <div class="DiaoyunlingDialog-list-page" v-if="'xiaoshouliang'==props.dialogPageType||'qiye-xiaoshouliang'==props.dialogPageType">
      <div class="DiaoyunlingDialog-list-item" v-for="(item,index) in listData" :key="index">
        <div class="DiaoyunlingDialog-list-item-pinzhong-view">
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">购买人：{{ item.farmerName }}</div>
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">联系方式：{{ item.mobilePhone }}</div>
        </div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">购买数量：{{ item.productionWeight }}公斤</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang">购买时间：{{ item.createTime }}</div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 10px;">种植地点：{{ item.location }}
        </div>
      </div>
    </div>
    <div class="DiaoyunlingDialog-list-page" v-if="'zhongzhinonghushu'==props.dialogPageType||'qiye-zhongzhinonghushu'==props.dialogPageType">
      <div class="DiaoyunlingDialog-list-item" v-for="(item,index) in listData" :key="index">
        <div class="DiaoyunlingDialog-list-item-pinzhong-view">
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">购买人：{{ item.farmerName }}</div>
          <div class="DiaoyunlingDialog-list-item-pinzhong-view1">联系方式：{{ item.mobilePhone }}</div>
        </div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang-view">
          <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 12px;">
            品种名称：{{ item.varietyName }}
          </div>
          <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 12px;">
            购买时间：{{ item.createTime }}
          </div>
        </div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang-view">
          <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 12px;">购买数量：{{ gmsl(item) }}
          </div>
          <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 12px;">
            种植面积：{{ item.productionArea }}亩
          </div>
        </div>
        <div class="DiaoyunlingDialog-list-item-diaoyongliang" style="font-size: 11px;">种植地点：{{ item.location }}
        </div>
      </div>
    </div>
  </div>

</template>
<script setup>
import {onMounted, ref, watch} from "vue";
import '@/views/zhuanjiyin/view/css/DiaoyunlingDialog.css'
import uiUtil from "@/util/UiUtil.js";

const props = defineProps({
  dilogShow: Function,
  user: Object,
  dialogTitle: String,
  dialogPageType: String,
  dialogData: Object//弹出框数据
});
console.log('DiaoyunlingDialog props.dialogData', props.dialogData)
const searchText = ref('')
const searchButtonClick = () => {
  getList()
}

onMounted(() => {
  console.log('dialog数据', props.dialogTitle, props.dialogPageType, props.dialogData)
  getList()
})

const placeholder = ref('请输入品种名称')

function getUrl() {
  var url = ''
  if ('diaoyunliang' == props.dialogPageType || 'qiye-diaoyunliang' == props.dialogPageType) {
    url = uiUtil.urlPath.searchDiaoYunList
    placeholder.value = '请输入品种名称'

    if ('qiye-diaoyunliang' == props.dialogPageType) {
      //http://114.242.25.97:20167/api/seedarchive/api/searchDiaoYunList?size=100&page=1&
      // varietyName=&realCompanyName=北京创种科技有限公司&region=999999&crop=
      realCompanyName.value = props.dialogData.companyName
    }
  } else if ('beianzhexinxi' == props.dialogPageType || 'mendiandaohuoliang' == props.dialogPageType
      ||'qiye-beianzhexinxi' == props.dialogPageType||'qiye-mendiandaohuoliang'== props.dialogPageType) {
    url = uiUtil.urlPath.searchArchiveList
    placeholder.value = '请输入品种名称'
    if ('qiye-beianzhexinxi' == props.dialogPageType||'qiye-mendiandaohuoliang'== props.dialogPageType){
      //http://114.242.25.97:20167/api/seedarchive/api/searchArchiveList?size=100&page=1&
      // varietyName=&realCompanyName=北京创种科技有限公司&region=999999&crop=
      realCompanyName.value = props.dialogData.companyName
      if ("3" == props.user.UserRoleID){
        //http://114.242.25.97:20167/api/seedarchive/api/searchArchiveList?size=100&page=1&varietyName=%E8%A3%95%E4%B8%B0303D&realCompanyName=北京联创种业有限公司&region=130108&crop=
        console.log('props.dialogData.varietyName=',props.dialogData.varietyName)
        searchText.value=props.dialogData.varietyName
      }
    }
  } else if ('xiaoshouliang' == props.dialogPageType || 'zhongzhinonghushu' == props.dialogPageType
  ||'qiye-xiaoshouliang'==props.dialogPageType||'qiye-zhongzhinonghushu'==props.dialogPageType) {
    url = uiUtil.urlPath.searchSaleList
    if ('qiye-xiaoshouliang'==props.dialogPageType||'qiye-zhongzhinonghushu'==props.dialogPageType){
      //http://114.242.25.97:20167/api/seedarchive/api/searchSaleList?size=100&
      // varietyName=&page=1&realCompanyName=北京创种科技有限公司&region=999999&crop=
      realCompanyName.value = props.dialogData.companyName
    }

  }
  console.log('url=', url)
  return url
}

const realCompanyName = ref('')

function requestData() {
  return {
    "size": 100,// "1",
    "page": 1,//"4",
    "varietyName": searchText.value,
    "region": props.dialogData.regionCode,
    "realCompanyName": realCompanyName.value,
    "crop": ""
  }
}

const listData = ref([])
const getList = () => {
  var url = getUrl()
  // debugger
  uiUtil.http().getObj({
    url: url,
    //   map = {HashMap@18623}  size = 6
    //   "size" -> {Integer@18676} 100
    // "page" -> {Integer@18678} 1
    // "varietyName" -> ""
    // "realCompanyName" -> ""
    // "region" -> "130000"
    // "crop" -> ""
    data: requestData(),
    start: function start() {
      uiUtil.toastLoading()
    },
    succeed: function succeed(res) {
      // debugger
      if (200 != res.code) {
        uiUtil.toastFail(res.msg)
        return
      }
      listData.value = res.data.records
      console.log('listData=', listData.value)
    },
    failed: function failed(res) {
    },
    finish: function finish() {
      uiUtil.toastClose()
    }
  })
};

function balx(value) {
  if (1 == value) {
    return '分支机构备案'
  } else if (2 == value) {
    return '委托代销备案'
  } else if (3 == value) {
    return '委托生产备案'
  } else if (4 == value) {
    return '经营不分装备案'
  }
  return ''
}

function gmsl(item) {
  if (uiUtil.isStrNull(item.productionWeight)) {
    return item.saleCount + '袋'
  } else {
    return item.productionWeight + '公斤'
  }
}
</script>

<style scoped lang="less">

</style>


<!--map = {HashMap@18623}  size = 6-->
<!--"size" -> {Integer@18676} 100-->
<!--"page" -> {Integer@18678} 1-->
<!--"varietyName" -> ""-->
<!--"realCompanyName" -> ""-->
<!--"region" -> "130000"-->
<!--"crop" -> ""-->